package activitytest.example.com.application.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.widget.AdapterView;

/**
 * Created by zhanyihong on 2017/12/6.
 */

public class SpUtils {

    private static SharedPreferences sp;

    public static  void  putBoolean(Context ctx, String key, boolean value){
        if (sp == null) {
            sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
      sp.edit().putBoolean(key,value).commit();
    }
    public static boolean getBoolean(Context ctx, String key, boolean defValue){
        if (sp == null) {
            sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        return sp.getBoolean(key,defValue);
    }
    public static  void  putString(Context ctx, String key, String value){
        if (sp == null) {
            sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
      sp.edit().putString(key,value).commit();
    }

    public static String getString(Context context, String key, String defValue){
        if (sp == null) {
            sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
        }
        return sp.getString(key,defValue);
    }
}
